<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:f="http://xmlns.jcp.org/jsf/core"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
    <h:head>
        <title>Naab'stro MyAdmin</title>
        <h:outputStylesheet name="styles.css" library="css"/>
        <h:outputStylesheet name="grid.css" library="css"/>
        <h:outputStylesheet name="tooltip.css" library="css"/>
        <h:outputStylesheet name="console.css" library="css"/>
    </h:head>
    <h:body>
        <f:view>
            <h:panelGroup id="wrapper" layout="block">
                <ui:include src="/resources/templates/header.xhtml"/>
                <h:panelGroup class="row" layout="block">
                    <h:panelGroup class="ten columns white-bg sp-azul" layout="block">
                        <h:panelGroup class="inner-columns" layout="block">
                            <h1>Selected DataBase : #{controllerWeb.selectedDb}</h1>
                            <h:form>
                                <h:selectOneMenu value="#{controllerWeb.selectedDb}">
                                    <f:selectItems value="#{controllerWeb.getDatabases()}" 
                                                   var="c" 
                                                   itemValue="#{c}" 
                                                   itemLabel="#{c}" />
                                </h:selectOneMenu>
                                <h:commandButton class="btn" value="Choose Database" action="#{controllerWeb.switchDatabase()}" />
                            </h:form>
                        </h:panelGroup>
                    </h:panelGroup>
                    <h:panelGroup class="galerie-wrap six columns white-bg sp-azul" layout="block">
                        <h:panelGroup class="inner-columns" layout="block">
                            <h1>Table : #{controllerWeb.selectedTable}</h1>
                            <h:form>
                                <h:selectOneMenu value="#{controllerWeb.selectedTable}">
                                    <f:selectItems value="#{controllerWeb.getTables()}" 
                                                   var="c" 
                                                   itemValue="#{c}" 
                                                   itemLabel="#{c}" />
                                </h:selectOneMenu>
                                <h:commandButton class="btn" value="Choose Table" action="#{controllerWeb.resetPagi()}"/>
                            </h:form>
                        </h:panelGroup>
                    </h:panelGroup>
                </h:panelGroup>

                <h:panelGroup class="row" layout="block">
                    <h:panelGroup class="galerie-wrap sixteen columns white-bg sp-azul" layout="block">
                        <h:panelGroup class="inner-columns overflow" layout="block">
                            <h1>Table's Content : </h1>
                            <p class="red error">#{controllerWeb.errMsg}</p>
                            <h:panelGroup layout="block">
                                <a href="insert.xhtml?mtable=#{controllerWeb.selectedTable}" class="btn">insert new row</a><a href="desc.xhtml" class="btn">Table's description</a>
                            </h:panelGroup>
                            <ul class="content-list">
                                <ui:repeat value="#{controllerWeb.tbc.entrySet().toArray()}" var="_entry"><li class="first">
                                        <span class="blue bold">
                                            <h:outputText value="#{_entry.key}"/>
                                        </span>

                                        <ul>
                                            <ui:repeat value="#{_entry.value}" var="_list"><li class="second">
                                                    <span>
                                                        <h:outputText value="#{_list}" escape="false"/>
                                                    </span>
                                                </li></ui:repeat>

                                        </ul>

                                    </li></ui:repeat>
                            </ul>
                        </h:panelGroup>
                        <ui:fragment rendered="#{controllerWeb.nbp > 0}">
                            <h:form>
                                <h:commandButton action="#{controllerWeb.previous30()}" value="&lt; 30 previous"/>
                            </h:form>
                        </ui:fragment>
                        <ui:fragment rendered="#{(controllerWeb.getTbcs() + 1) >= (controllerWeb.getNbpage() + 1) }">
                            <h:form>
                                <h:commandButton action="#{controllerWeb.next30()}" value="30 next &gt;"/>
                            </h:form>
                        </ui:fragment>
                    </h:panelGroup>
                </h:panelGroup>
                <ui:include src="/resources/templates/footer.xhtml"/>
            </h:panelGroup>
            #{controllerWeb.setErrMsg("")}
        </f:view>
    </h:body>
</html>

